package xyz.zdsoft.user_info_manage_module.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.user_info_manage_module.pojo.EditTeacherParameter;
import xyz.zdsoft.user_info_manage_module.pojo.InsertTeacherParameter;
import xyz.zdsoft.user_info_manage_module.pojo.TeacherInfo;
import xyz.zdsoft.user_info_manage_module.pojo.TeacherInfoParameter;
import xyz.zdsoft.user_info_manage_module.service.Impl.TeacherInfoManagementServiceImpl;

import javax.annotation.Resource;


/**
 * 教师信息管理控制
 * @author 以风
 */
@Api(tags = "教师信息管理")
@RequestMapping("/api/admin/teacherInfoManagement")
@RestController
public class TeacherInfoManagementController {
    @Resource
    private TeacherInfoManagementServiceImpl teacherInfoManagementService;

    @PostMapping("/getTeacherInfoByPage")
    @ApiOperation(value = "获取教师信息列表（分页、查询、重置）")
    public Result<IPage<TeacherInfo>> getTeacherInfoByPage(TeacherInfoParameter teacherInfoParameter){
        IPage<TeacherInfo> page = new Page<TeacherInfo>(teacherInfoParameter.getCurrent(), teacherInfoParameter.getSize());
        IPage<TeacherInfo> teacherInfoIPage = teacherInfoManagementService.selectPageVo(page,teacherInfoParameter);
        return Result.ok().message("获取教师信息列表成功").data(teacherInfoIPage);
    }

    @PostMapping("/insertTeacher")
    @ApiOperation(value = "新增")
    public Result insertTeacher(InsertTeacherParameter insertTeacherParameter){
        Result result = teacherInfoManagementService.insertTeacher(insertTeacherParameter);
        return result;
    }

    @PostMapping("/editTeacher")
    @ApiOperation(value = "编辑")
    public Result editTeacher(EditTeacherParameter editTeacherParameter){
        Result result = teacherInfoManagementService.editTeacher(editTeacherParameter);
        return result;
    }

    @GetMapping("/disableOrEnable")
    @ApiOperation(value = "停用或启用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "教师id",required = true),
            @ApiImplicitParam(name = "delFlag",value = "停用或启用，0：启用，1：停用",required = true)
    })
    public Result disableOrEnable(Long id,String delFlag){
        Result result = teacherInfoManagementService.disableOrEnable(id,delFlag);
        return result;
    }

}
